<?php

namespace App\Entity\Trade;

use ApiPlatform\Core\Annotation\ApiResource;
use App\Base\Annotation\Common;
use App\Entity\Lang\LangPack;
use App\Repository\Trade\ProductTradeRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ApiResource()
 * @ORM\Entity(repositoryClass=ProductTradeRepository::class)
 */
class ProductTrade
{
    /**
     * @Common(cnName="#",listType="text",editType="text")
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     * @Groups({"prod"})
     */
    private $id;

    /**
     * @Common(cnName="品名",listType="text",editType="text",width="")
     * @ORM\Column(type="string", length=255, nullable=true)
     * @Groups({"prod"})
     */
    private $name;

    /**
     * @Common(cnName="图片",listType="pic",editType="pic",width="300")
     * @ORM\Column(type="string", length=255, nullable=true)
     * @Groups({"prod"})
     */
    private $pic;

    /**
     * @Common(cnName="介绍",listType="textarea",editType="textarea")
     * @ORM\Column(type="text", nullable=true)
     * @Groups({"prod"})
     */
    private $intro;

    /**
     * @Common(cnName="语言包",listType="textarea",editType="textarea")
     * @ORM\ManyToOne(targetEntity=LangPack::class)
     * @Groups({"prod"})
     */
    private $lang;

    /**
     * @Common(cnName="分类",listType="textarea",editType="textarea")
     * @ORM\ManyToOne(targetEntity=CategoryTrade::class, inversedBy="price")
     * @Groups({"prod"})
     */
    private $cat;

    /**
     * @Common(cnName="价格",listType="textarea",editType="textarea")
     * @ORM\Column(type="array")
     * @Groups({"prod"})
     */
    private $price = [];

    /**
     * @Common(cnName="折扣(%)",listType="textarea",editType="text")
     * @ORM\Column(type="float", nullable=true)
     * @Groups({"prod"})
     */
    private $cut;

    /**
     * 如果启用折扣，true则按照商品折扣计算价格，false则按照会员折扣计算价格
     * @Common(cnName="启用折扣",listType="textarea",editType="switch")
     * @ORM\Column(type="boolean")
     * @Groups({"prod"})
     */
    private $useCut;

    /**
     * @Common(cnName="上架",listType="textarea",editType="switch")
     * @ORM\Column(type="boolean")
     * @Groups({"prod"})
     */
    private $isOn;

    /**
     * @Common(cnName="详情图",listType="textarea",editType="pics")
     * @ORM\Column(type="array", nullable=true)
     * @Groups({"prod"})
     */
    private $pics;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(?string $name): self
    {
        $this->name = $name;

        return $this;
    }

    public function getPic(): ?string
    {
        return $this->pic;
    }

    public function setPic(?string $pic): self
    {
        $this->pic = $pic;

        return $this;
    }

    public function getIntro(): ?string
    {
        return $this->intro;
    }

    public function setIntro(?string $intro): self
    {
        $this->intro = $intro;

        return $this;
    }

    public function getLang(): ?LangPack
    {
        return $this->lang;
    }

    public function setLang(?LangPack $lang): self
    {
        $this->lang = $lang;

        return $this;
    }

    public function getCat(): ?CategoryTrade
    {
        return $this->cat;
    }

    public function setCat(?CategoryTrade $cat): self
    {
        $this->cat = $cat;

        return $this;
    }

    public function getPrice(): ?array
    {
        return $this->price;
    }

    public function setPrice(array $price): self
    {
        $this->price = $price;

        return $this;
    }

    public function getCut(): ?float
    {
        return $this->cut;
    }

    public function setCut(?float $cut): self
    {
        $this->cut = $cut;

        return $this;
    }

    public function getUseCut(): ?bool
    {
        return $this->useCut;
    }

    public function setUseCut(bool $useCut): self
    {
        $this->useCut = $useCut;

        return $this;
    }

    public function getIsOn(): ?bool
    {
        return $this->isOn;
    }

    public function setIsOn(bool $isOn): self
    {
        $this->isOn = $isOn;

        return $this;
    }

    public function getPics(): ?array
    {
        return $this->pics;
    }

    public function setPics(?array $pics): self
    {
        $this->pics = $pics;

        return $this;
    }
}
